﻿#region Using's

using System;
using System.Diagnostics;

using MyUtils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Test.MyUtils.TestHelp;

#endregion

namespace Test.MyUtils
{
	[Serializable]
	public class MyMsg
	{
		public string CtorParam;
		public string DomainName;
		public string Message;
	}

	[Serializable]
	public class MyRemoteClass : MarshalByRefObject
	{
		public MyMsg Run(string cmd)
		{
			return new MyMsg
			{
				Message = cmd.ToUpperInvariant(),
				DomainName = AppDomain.CurrentDomain.FriendlyName,
			};
		}
	}

	[TestClass]
	public class TestSeparateDomain : FixtureMsTest
	{
		[TestMethod]
		public void Test()
		{
			using (var dom = new SeparateDomain())
			{
				var r = dom.Execute<MyRemoteClass, MyMsg>(x => x.Run("runP"));
				Equal("RUNP", r.Message);
				Trace.WriteLine(r.DomainName);
				False(r.DomainName == AppDomain.CurrentDomain.FriendlyName);
			}
		}
	}
}